/**
 * This class is designed to be used in both website and android.
 * <p/>
 * zhaoxu @ 2012-05-24 14:20
 * <p/>
 */
package com.threeti.mecool.core.domain.model.plan.pojo;

import org.codehaus.jackson.annotate.JsonBackReference;
import org.codehaus.jackson.annotate.JsonIgnore;

public class RouteStepItem {
	private Long id;
	private Integer version;
	private RouteStep routeStep;
	private String text;
	private Step nextStep;
	private transient Long nextStepId;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@JsonBackReference
	public RouteStep getRouteStep() {
		return routeStep;
	}

	public void setRouteStep(RouteStep routeStep) {
		this.routeStep = routeStep;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	@JsonIgnore
	public Step getNextStep() {
		if (nextStep == null && nextStepId != null) {
			nextStep = routeStep.getJob().findStepById(nextStepId);
		}
		return nextStep;
	}

	public void setNextStep(Step nextStep) {
		this.nextStep = nextStep;
	}

	public Long getNextStepId() {
		if (nextStepId == null && nextStep != null) {
			nextStepId = nextStep.getId();
		}
		return nextStepId;
	}

	public void setNextStepId(Long nextStepId) {
		this.nextStepId = nextStepId;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

}
